﻿
Namespace Aricie.DNN.Modules.LuceneSearch.Filtering

    Public Class FilterRulesManagerFactory
        Implements IFilterRulesManagerFactory


        Private _IFRM As IFilterRulesManager = Nothing

        Friend Sub New(IFRM As IFilterRulesManager)
            _IFRM = IFRM
        End Sub

        Public Function Create() As IFilterRulesManager Implements IFilterRulesManagerFactory.Create
            Return _IFRM
        End Function

        Public Function Expects(Of T)(Label As String) As IFilterRulesManagerFactory Implements IFilterRulesManagerFactory.Expects
            _IFRM.AddRule(New FilterRule() With {.Label = Label, .MatchingType = GetType(T)})
            Return Me
        End Function

        Public Function ExpectsComplex(Label As String, validator As System.Func(Of Lucene.Net.Search.BooleanQuery, Boolean)) As IFilterRulesManagerFactory Implements IFilterRulesManagerFactory.ExpectsComplex
            _IFRM.AddRule(New FilterRule() With {.Label = Label, .InnerVerification = validator, .MatchingType = GetType(Lucene.Net.Search.BooleanQuery)})
            Return Me
        End Function
    End Class

End Namespace